﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Petroleum.Tool;
using HZH_Controls.Forms;
using Petroleum.DB.Model;
using Petroleum.Model;

namespace Petroleum.UC
{
    public partial class StepTemplate : UserControl
    {
        FormMain main = new FormMain();
        public StepTemplate(FormMain main)
        {
            InitializeComponent();
            this.main = main;
            this.txtDesignTVD.KeyDown += new System.Windows.Forms.KeyEventHandler(ASYTool.TextBox_KeyPress);
            //txtGL.KeyDown += new System.EventHandler(this.btnDown_BtnClick);  ;
        }

        private void label5_Click(object sender, EventArgs e)
        {

        }

        private void btnTest_BtnClick(object sender, EventArgs e)
        {
            var left =  ASYTool.GetControll(groupLeft);
            var right = ASYTool.GetControll(groupRight);
            Console.WriteLine("当前窗口一共" + (left.Count + right.Count) + "个输入框。");
            FrmDialog.ShowDialog(this, left+"\n"+right);
            //labTest.Text = "当前窗口一共" + (left.Count + right.Count) + "个输入框。";
        }

        private void btnDown_BtnClick(object sender, EventArgs e)
        {
            Session.BasicInf = GetControl();
            LogHelper.WriteLog("Step1下一步，井口名称：" + Session.BasicInf.WellName);
            main.AddControl(new Step2FormationPressurePrediction(main));
            
        }

        public BasicInf GetControl ()
        {
            return new BasicInf()
            {
                WellName = txtWellName.InputText,
                TrajectoryType = txtTrajectoryType.InputText,
                WellType = txtWellType.InputText,
                LocationOfGeoStructure = txtLocation.InputText,
                NameOfGeoStructure=txtNameOGS.InputText,
                PurposeOfDrilling = txtPurposeOfDrilling.InputText,
                TargetFormation = txtTarget.InputText,
                WellCompletionMethod = txtWellCM.InputText,
                TDCriterion = txtTDcriterion.InputText,
                Wellhead = new WellheadCoordinates() 
                {
                    Longitude = txtLocation.InputText,
                    Latitude = txtLatitude.InputText
                },
                GL = txtGL.InputText,
                KB = ASYTool.IsNumeric(txtKB.InputText) ? decimal.Parse(txtKB.InputText) : 0,
                SSTVD = ASYTool.IsNumeric(txtSSTVD.InputText) ? decimal.Parse(txtSSTVD.InputText) : 0,
                DesignTVD = ASYTool.IsNumeric(txtDesignTVD.InputText) ? decimal.Parse(txtDesignTVD.InputText) : 0,
            };
        }

        private void txtDesignTVD_KeyDown(object sender, KeyEventArgs e)
        {

        }
    }
}
